const avro = require('avsc');
fs = require('fs');

fs.readFile("meta-lib-static/avsc/dcSdkPlatformBulk.avsc", "utf8", function (err, schemaText) {
	if (err) return ;
	const schema = avro.Type.forSchema(JSON.parse(schemaText)) ;
	fs.readFile("meta-lib-static/sample/web.EventClick.pretty.json", "utf8", function (err, dataText) {
	// fs.readFile("meta-lib-static/sample/web.EventViewPage.pretty.json", "utf8", function (err, dataText) {
	// fs.readFile("meta-lib-static/sample/web.EventCustom.pretty.json", "utf8", function (err, dataText) {
    if(err) return ;
    const buf = schema.toBuffer(JSON.parse(dataText)) ;
    const val = schema.fromBuffer(buf); 
    console.log(val) ;
  })
}) ;

